package com.firewolf.spring.aop;

import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

/**
 * 观众，通知类，会在表演的各个时机做一些事情
 * @author lx
 *
 */
@Aspect
@Component
public class Audience {
	
	private final String EXECUTION = "execution(* com.firewolf.spring.aop.Performer.perform(..))";
	
	
	/** 表演前找位置坐下*/
	@Before(EXECUTION)
	public void takeSeats(){
		System.out.println("听众找位置坐下");
	}
	
	/** 表演前关闭手机*/
	@Before(EXECUTION)
	public void turnOffPhone(){
		System.out.println("关闭手机");
	}
	
	/** 表演返回之后*/
	@AfterReturning(EXECUTION)
	public void applaud(){
		System.out.println("表演相当精彩，听众鼓掌");
	}
	
	/** 表演结束后*/
	@After(EXECUTION)
	public void leave(){
		System.out.println("表演结束了，回家啦");
	}
	
	
	/** 表演相当失败*/
	@AfterThrowing(EXECUTION)
	public void demandRefund(){
		System.out.println("表演真的好垃圾");
	}
}
